package cn.net.yugu.doraemon.event.engine;

import java.util.List;

import cn.net.yugu.doraemon.api.common.event.EventHandler;
import com.google.common.eventbus.EventBus;
import lombok.RequiredArgsConstructor;

/**
 * @author xiangzhurui
 * @version 2022/11/9 13:09:48
 */
@RequiredArgsConstructor
public class EventHandlerRegistry {

    private final List<EventHandler> eventHandlers;

    private final EventBus eventBus;

    private final EventBus asyncEventBus;

    public void init() throws Exception {
        eventHandlers.forEach(eventHandler -> {
            eventBus.register(eventHandler);
            asyncEventBus.register(eventHandler);
        });
    }
}
